package com.qf.contorller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.qf.pojo.Order;
import com.qf.pojo.R;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@RestController
@RequestMapping("/order")
public class OrderContorller {

    @Autowired
    OrderService orderService;

    @GetMapping("/{id}")
    @SentinelResource("findByUid")
    public R findByUid(@PathVariable("id") Integer id, HttpServletRequest request) throws InterruptedException {

        System.out.println("param:" + request.getParameter("red"));
        System.out.println("header:" + request.getHeader("X-Request-red"));

        List<Order> orders = orderService.findByUid(id);
        return R.success().putData(orders);
    }
}
